﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wwtfly.BBS.Framework.Attributes
{
    [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
    public class DropListItemAttribute : Attribute
    {
        /// <summary>
        /// 获取数组列表
        /// </summary>
        /// <param name="str">字符串格式：1;2|3;4|5;6</param>
        public DropListItemAttribute(string str)
        {
            List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();

            string[] arrList = str.Split('|');
            if (arrList != null && arrList.Length > 0)
            {
                foreach (string a in arrList)
                {
                    Dictionary<string, string> dict = new Dictionary<string, string>();
                    string[] arr = a.Split(';');
                    if (arr != null && arr.Length > 0)
                    {
                        dict["Text"] = arr[0].ToString();
                        dict["Value"] = arr[1].ToString();
                    }
                    list.Add(dict);
                }
            }
            _ItemList = list;
        }

        private List<Dictionary<string, string>> _ItemList;
        /// <summary>
        /// 返回字典列表
        /// </summary>
        public List<Dictionary<string, string>> ItemList
        {
            get
            {
                return _ItemList;
            }
        }
    }

}
